﻿@using FoodEx.Domain.Resources

<div class="navbar navbar-inverse navbar-fixed-top">
	<div class="navbar-inner">
		<div class="container">
			<a class="brand" href="#">FoodEx</a>
			<div class="nav-collapse collapse">
				<ul class="nav">
					@MenuItem(@FoodEx.Patients,"Patient")
				</ul>
			</div>
		</div>
	</div>
</div>

@functions
{
	IHtmlString MenuItem(string text, string controller, string action = "index")
	{
		var currentController = (string)ViewContext.RouteData.Values["controller"];
		var currentAction = (string)ViewContext.RouteData.Values["action"];
		
		bool isCurrentAction = String.Compare(currentAction, action, StringComparison.OrdinalIgnoreCase) == 0;
		bool isCurrentController = String.Compare(currentController, controller, StringComparison.OrdinalIgnoreCase) == 0;
		
		return ListItem(text, controller, action, isCurrentAction && isCurrentController);
	}
}
@helper	ListItem(string text, string controller, string action, bool isCurrent)
{
	if (isCurrent)
	{
		<li class="active">@Html.ActionLink(text, action, controller)</li>	
	}
	else
	{  
		<li>@Html.ActionLink(text, action, controller)</li>
	} 
}
